<template>
  <view class="whole">
    <view class="nowPoint">
      <view class="nowPoint_left">当前拥有的积分：</view>
      <view class="nowPoint_right">{{
        walletDetail ? walletDetail.point : 0
      }}</view>
    </view>

    <view class="notice">转账积分：</view>
    <view class="bootm">
      <input
        class="modal-input"
        type="text"
        v-model="point"
        placeholder="请输入转账到积分商城的积分数额"
        placeholder-style="font-size:32rpx"
        style="font-size: 32rpx"
      />
    </view>

    <view class="button" @click="handleTransfer">确认转账</view>

    <u-popup
      v-model="show_operation_password"
      mode="center"
      width="490rpx"
      height="290rpx"
      :border-radius="24"
      :closeable="true"
      :mask-close-able="false"
    >
      <view class="Transaction_eject">
        <text class="Transaction_top">输入交易密码</text>
        <input
          type="password"
          value=""
          class="Transaction_center"
          v-model="operation_password"
        />
        <text class="Transaction_bottom" @click="Submit">确定</text>
      </view>
    </u-popup>
  </view>
</template>

<script>
import api from "../../api/api";
import tip from "@/utils/tip.js";
export default {
  data() {
    return {
      point: "",
      operation_password: "",
      show_operation_password: false,
      walletDetail: null,
    };
  },
  onShow() {
    this.getuserWallet();
  },
  methods: {
    async getuserWallet() {
      let res = await api.userWallet({ method: "get", loading: "加载中" });

      if (res.code === 0) {
        this.walletDetail = res.data;
      } else {
        tip.defaults(res.msg);
      }
    },
    handleTransfer() {
      if (this.point == "") {
        tip.defaults("请输入转账积分");
        return;
      }
      
      this.show_operation_password = true;
    },
    async Submit() {
      let res = await api.pointToPointMarket({
        query: {
          operation_password: this.operation_password,
          point: this.point,
        },
        method: "post",
      });

      this.show_operation_password = false;
      this.operation_password = "";
      if (res.code == 0) {
        tip.defaults("提交成功");
      } else {
        tip.defaults(res.msg);
      }
    },
  },
};
</script>

<style lang="scss" scoped>
@import "../../style/yuanchuang.scss";
.whole {
  background-color: $bg-color1;
  min-height: 100vh;
  .input_top {
    color: #bbbbbe;
    height: 100rpx;
    margin-left: 30rpx;
  }
  .input_center {
    color: #ffffff;
    // height: 260rpx;
    padding: 30rpx 0 100rpx;
    margin-left: 30rpx;
    word-break: break-all;
  }
  .input {
    position: relative;
    top: 30rpx;
    background-color: $bg-color3;
    color: #ffffff;
  }
  .upload_upload {
    display: flex;
    align-content: flex-start;
  }
  .upload {
    margin-top: 20rpx;
    background-color: $bg-color3;
    height: 300rpx;
    padding-left: 20rpx;
  }
  .notice {
    margin: 30rpx;
    // width: 160rpx;
    height: 44rpx;
    font-size: 32rpx;
    font-weight: 400;
    color: #ffffff;
    line-height: 44rpx;
  }
  .bootm {
    background-color: $bg-color3;
    display: flex;
    align-items: center;
    // padding: 10rpx;
    padding: 30rpx 40rpx;
    .set_name {
      padding: 20rpx 30rpx;
      color: #bbbbbe;
      font-size: 32rpx;
    }
    .modal-input {
      width: 100%;
      color: #ffffff;
    }
  }
  .button {
    position: relative;
    top: 100rpx;
    margin: 30rpx;
    height: 90rpx;
    color: $text-color4;
    background: $button;
    background-repeat: no-repeat;
    background-size: 100%;
    text-align: center;
    line-height: 90rpx;
    font-size: 32rpx;
    border-radius: 16rpx;
  }
  .upload_img {
    margin-left: 20rpx;
    // margin-top: 10rpx;
    width: 85rpx;
    height: 85rpx;
    padding: 45rpx;
    background-color: #999999;
  }
}
.fixed {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;

  width: 750rpx;
  height: 130rpx;
  background: #292b2b;
  &_button {
    width: 670rpx;
    height: 90rpx;
    margin: 20rpx auto 0;
    background: $button;
    background-repeat: no-repeat;
    background-size: 100%;

    font-size: 32rpx;
    font-weight: 400;
    color: #ffffff;
    line-height: 90rpx;
    text-align: center;
  }
}
.review {
  padding-top: 76rpx;
  width: 530rpx;
  height: 580rpx;
  background: #292b2b;
  border-radius: 22rpx;
  text-align: center;

  &_image {
    width: 300rpx;
    height: 320rpx;
  }
  &_row1 {
    margin-top: 20rpx;
    // width: 160rpx;
    height: 44rpx;
    font-size: 32rpx;
    font-weight: 400;
    color: #ffffff;
    line-height: 44rpx;
  }
  &_row2 {
    margin-top: 10rpx;
    // width: 120rpx;
    height: 34rpx;
    font-size: 24rpx;
    font-weight: 400;
    color: #ffffff;
    line-height: 34rpx;
  }
}
.fail {
  padding-top: 50rpx;
  text-align: center;
  &_image {
    width: 60rpx;
    height: 60rpx;
  }
  &_row1 {
    margin-top: 14rpx;
    // width: 144rpx;
    height: 50rpx;
    font-size: 36rpx;
    font-weight: 500;
    color: #ffffff;
    line-height: 50rpx;
  }
  &_row2 {
    margin-top: 10rpx;
    // width: 392rpx;
    height: 40rpx;
    font-size: 28rpx;
    font-weight: 400;
    color: #1fe7e7;
    line-height: 40rpx;
  }
}
.Transaction_eject {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  height: 290rpx;
  background-color: $bg-color1;
  .Transaction_top {
    margin-top: 50rpx;
    font-size: 32rpx;
    color: $text-color1;
  }
  .Transaction_center {
    padding: 0 20rpx;
    border: 2rpx solid #262934;
    background: $bg-color3;
    border-radius: 16rpx;
    height: 85rpx;
    width: 80%;
    color: #ffffff;
  }
  .Transaction_bottom {
    font-size: 32rpx;
    color: $text-color1;
    margin-bottom: 30rpx;
  }
}
.nowPoint {
  padding: 0 30rpx;
  width: 750rpx;
  height: 104rpx;
  background: #292b2b;
  display: flex;
  align-items: center;
  justify-content: space-between;
  &_left {
    // width: 256rpx;
    height: 44rpx;
    font-size: 32rpx;
    font-weight: 400;
    color: #ffffff;
    line-height: 44rpx;
  }
  &_right {
    // width: 96rpx;
    height: 44rpx;
    font-size: 32rpx;
    font-weight: 500;
    color: #ffffff;
    line-height: 44rpx;
  }
}
</style>
